<?php include"shared/head.php";?>

<?php
$username=$_POST["username"];
$password=$_POST["password"];
if (isset($_POST["login"]))
{
    include "shared/conn.php";
    mysqli_select_db($conn, 'personalterm');
    mysqli_query($conn, "set names 'utf-8");

//    $sql_username_onlyone=" SELECT * FROM `user` WHERE username='{$username}'";
//    $result1=mysqli_query($conn, $sql_username_onlyone);
//    if (count(mysqli_fetch_all($result1)))>=1)
//        {
//
//
//        }
//
    $sql_user=" SELECT * FROM `user` WHERE username='{$username}' AND password='{$password}'";
    $result=mysqli_query($conn, $sql_user);
    if (count(mysqli_fetch_all($result))==1)
    {
        session_start();
        $_SESSION["username"]=$username;
        header("Location:index.php");
    }
        else
        {
            echo "<script>alert('{$login_error}')</script>";
        }

}

?>



<form action=" " method="POST" class="input-group mb-3">
        <div class="input-group-prepend">
            <span class="input-group-text" id="inputGroup-sizing-default"><?php echo $s_username_lable; ?></span>
            <input type="text" name="username" class="form-control input-group mb-3" aria-label="Default" aria-describedby="inputGroup-sizing-default">
        </div>
        <div class="input-group-prepend">
            <span class="input-group-text" id="inputGroup-sizing-default"><?php echo $s_password_lable; ?></span>
            <input type="password" name="password" class="form-control" aria-label="Default" aria-describedby="inputGroup-sizing-default">
        </div>
    <div>
    <button name="login"><?php echo $s_login_button; ?></button>
    </div>
</form>


<?php include"shared/foot.php";?>
